package newcoder;

import com.sun.org.apache.xpath.internal.operations.String;

public class NC88 {
    public int findKth(int[] a, int n, int K) {
        // write code here
        return quicksort(a,0,n-1,K);
    }
    public int quicksort(int[] a, int low,int high,int K){
        int p =a[low];
        int i = low,j = high;
        while(i<j){
            while(i<j&&a[j]>=p) j--;
            while(i<j&&a[i]<=p) i++;
            if(i<j){
                int temp = a[i];
                a[i] = a[j];
                a[j] = temp;
            }
        }
        a[low] = a[i];
        a[i] = p;
        if(i==a.length-K) return a[i];
        else if(i<a.length-K) return quicksort(a,i+1,high,K);
        else return quicksort(a,low,i-1,K);
    }

    public static void main(String[] args) {
        NC88 t =new NC88();
        System.out.println(t.findKth(new int[]{7,4,1,6,9,2},6,2));
        System.out.println('4'-'0');
        System.out.println((int)'4');
        System.out.println(4+'0');

    }
}
